<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生命周期</title>
    <script src="dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="username" @keyup="getData">
        {{ username}}
    </div>
</body>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
            username: ''
        },
        methods: {
            getData() {
                if(this.username=='1234') {
                    this.$destroy();
                }
            }
        },
        beforeCreate () {
            console.log('beforeCreate')
        },
        created () {
            console.log('created')
        },
        beforeMount () {
            console.log('beforeMount')
        },
        mounted () {
            console.log('mounted')
        },
        beforeUpdate () {
            console.log('beforeUpdate')
        },
        updated () {
            console.log('updated')
        },
        beforeDestroy () {
            console.log('beforeDestroy')
        },
        destroyed () {
            console.log('destroyed')
        }
    })
</script>
</html>